package com.security.service;

import com.security.bean.Blog;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @ClassName: TestService
 * @Author: ZhangYue26
 * @Description:
 * @Date: 2021-01-20
 */
@Service
public class TestService {
    private List<Blog> list = new ArrayList<>();

    public TestService() {
        list.add(new Blog("user", 1L, "普通用户"));
        list.add(new Blog("admin", 2L, "管理员用户"));
    }

    public List<Blog> getBlogs() {
        return list;
    }

    public void deleteBlogs(long id) {
        Iterator<Blog> iterator = list.iterator();
        while (iterator.hasNext()) {
            Blog blog = iterator.next();
            if (blog.getId() == id) {
                iterator.remove();
            }
        }
    }

}
